from  rest_framework import serializers

from .models import News,NewsCategory,Comment,Banner
from apps.xfzauth.serializers import UserSerializers

class NewCategorySerializers(serializers.ModelSerializer):
    class Meta:
        model = NewsCategory
        fields = ('id','name')
class NewsSerializers(serializers.ModelSerializer):
    category = NewCategorySerializers()
    author = UserSerializers()
    class Meta:
        model = News
        fields = ('id','title','thumbnail','desc','pub_time','author','category')

class CommentsSerializers(serializers.ModelSerializer):
    class Meta:
        model = Comment
        fields = ('id', 'content','author','pub_time')

class BannerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Banner
        fields = ('id','image_url','priority','link_to')